	var $user_id  = $("#user_id").val();
	var $order_id;
	var $order_package_id;
	var order_status = $(".order-status li").find("a").attr("data-status");//获取待付款，待发货，待收货，待评价状态码
	var num = 10;
    var count;
    var page_no = 1;
//点击切换状态，待付款，待发货，待收货，待评价
$(".order-status li").live("click",function(){
	page_no = 1;
    $(".list-status").html("");
    order_status = $(this).find("a").attr("data-status");
	$(this).addClass("cur").siblings().removeClass("cur");
     index_ajax();
});
   // 加载更多js
$(".moreshow").live("click",function(){
		       page_no++;
		      index_ajax();

		})
// 判断小圆圈里面的数量3位数的时候

$(".order-status li .num").each(function() {
    if(parseInt($(this).text())>99){
        $(this).text("9+");
    }
});
function num_subtraction(){

}
//无订单页面效果
function notfound(){
	var noorder = "";
	noorder += '<div class="nodata">'+
					'<p class="no-icon wdorder"></p>'+
					'<p class="nodatatip">还有没有相关的订单哦~</p>'+
				'</div>';
			if($(".nodata").length < 1){
				$(".loadBtn").remove();
				$("body").append(noorder);
              }
}

// ajax请求数据js
 function index_ajax(){
	 $.ajax({
            type:"post",
            url:"../../order/Index/getOrderList",
            dataType:"json",
            data:{"user_id":$user_id,"order_id":$order_id,"orderState":order_status,"page_no":page_no,"page_size":num},
            beforeSend:function(){
             $(".nodata").remove();
            	$(".loading").show();
            },
            success:function(msg){
            	$(".loading").hide();
            	//$(".list-status").html("");
                    var boxes = [];
                    var datalength;
                    if(page_no == 1 && msg.stdclass.list==null){
                    		notfound();
                    		return false;
                    }
                    datalength=msg.stdclass.list.length;
                    function change(){
                            for (var i=0; i < datalength; i++ ) {
                            	var detailsrc,detaillongName,
                            	detailprice,detailspecs,
                            	detailcount,detailreallyprice;
                            	var detail="";
                                var detailstatus;
                                var  $orderStateName = msg.stdclass.list[i].orderState;
                                if($orderStateName =='10'){//10-待付款
                                      detailstatus = '<a href="javascript:" class="pay fr fukuan">付款</a>'+
                                                     '<a href="javascript:" class="fr wypj abolish mr-right-20">取消订单</a>';
                                }
                                if($orderStateName =='15'){//15-支付中
                                      detailstatus = '<a href="javascript:" class="fr wypj fukuan">付款</a>';
                                }
                                if($orderStateName =='20'){//20-已付款(待发货)
                                      detailstatus =  '<b  class="redword fr">等待发货</b>';
                                }
                                if($orderStateName =='40'){//40-已发货(待收货)
                                      detailstatus =  '<a href="javascript:" class="fr qrsh">确认收货</a>';
                                }
                                if($orderStateName =='50'){//50-交易完成(已收货)
                                	if(msg.stdclass.list[i].isEvaluate){
                                    // detailstatus = '';
                                     }else{
                                     	   detailstatus = '<a href="/product/Index/promotionAddEva?order_id='+msg.stdclass.list[i].orderId+'&package_id='+msg.stdclass.list[i].orderPackageId+'" class="wypj fr">我要评价</a>';
                                     }
                                    detailstatus += '<a href="javascript:" class="fr wypj delete mr-right-20">删除订单</a>';
                                }
                                if($orderStateName =='-3'){//-3-订单已取消
                                      detailstatus = '<a href="javascript:" class="fr wypj delete mr-right-20">删除订单</a>';
                                }

                            	for(var j=0;j<msg.stdclass.list[i].proAndSkuDetail.length;j++){
                            		detailsrc = msg.stdclass.list[i].proAndSkuDetail[j].src;
                            		detaillongName = msg.stdclass.list[i].proAndSkuDetail[j].longName;
                            		detailprice = msg.stdclass.list[i].proAndSkuDetail[j].price;
                            		detailspecs = msg.stdclass.list[i].proAndSkuDetail[j].specs;
                            		detailcount = msg.stdclass.list[i].proAndSkuDetail[j].count;
                            		detailreallyprice = parseFloat(detailprice * detailcount).toFixed(2);
                            		detail+='<dl class="goods_infor clearfix">'+
		    	 		'<dt class="fl">'
		    	 			+'<a href="/order/index/orderDetail?user_id='+msg.stdclass.list[i].userId+'&oto_order_id='+msg.stdclass.list[i].orderId+'"><img src="'+detailsrc+'" /></a>'+
		    	 		'</dt>'+
		    	 		'<dd class="fl">'+
		    	 			'<p class="shop-name clearfix">'+
		    	 				'<a href="/order/index/orderDetail?user_id='+msg.stdclass.list[i].userId+'&oto_order_id='+msg.stdclass.list[i].orderId+'"><span class="fl">'+detaillongName+' </span></a>'+
		    	 				'<span class="fr redword">￥<b class="fblod">'+detailprice+'</b></span>'+
		    	 			'</p>'+
		    	 			'<p class="goods-name clearfix">'+
		    	 				'<a href="javascript:"><span class="fl">'+detailspecs+' </span></a>'+
		    	 				'<span class="fr amount">X<i>'+detailcount+'</i></span>'+
		    	 			'</p>'+
		    	 			'<p class="goods-total">'+
		    	 				  ' <span class="fr">实付: <i class="redword">￥<b class="fblod">'+detailreallyprice+'</b></i></span>'+
		    	 			'</p>'+
		    	 		'</dd>'+
		    	 	'</dl>';
                            	}
     						boxes.push('<li class="dfk">'+'<div class="name clearfix">'+
				 				'<span class="fl goods">订单号：'+msg.stdclass.list[i].orderId+'</span>'+
				 				'<span class="name_status fr">'+msg.stdclass.list[i].orderStateName+'</span>'+'</div>'+
				 			detail+
		    	 	 '<div class="fk clearfix">'+
		    	 	 	 '<span class="fl">共'+msg.stdclass.list[i].proAndSkuCount +'件商品</span>'+
		    	 	 	detailstatus+
		    	 	 '</div>'+'<input type="hidden" value="'+msg.stdclass.list[i].orderId+'" class="order_id">'+'<input type="hidden" value="'+msg.stdclass.list[i].orderPackageId+'" class="order_package_id">'+
				 		'</li>');
                            }
                            return boxes.join("");
                        }
                      var $boxes = $(change());
                     $(".nodata").remove();
                     $(".list-status").append($boxes);
                     count=msg.stdclass.total;
                     var $loadBtn = '<div class="loadBtn"><a href="javascript:;" class="moreshow"><b></b>加载更多</a></div>';
                     if($(".list-status li").length<count){
                         if($(".loadBtn").length<1){

                         	$("body").append($loadBtn);
                       }

                    }else{
                    	$(".loadBtn").remove();
                    	 }


            }
        })
 }

 //删除订单
 var $pop_h = $(".pop").height();
 var $pop_w = $(".pop").width();
 var $win_h =  $(window).height();
 var $win_w=  $(window).width();
 $(".pop").css({"top":($win_h-$pop_h)/2+"px","left":($win_w-$pop_w)/2+"px"});
 var index_info;
 //删除订单
  $(".delete").live("click",function(){
       $(".popback").show();
       $(".poptagwindow").show();
       index_info = $(this).parents("li").index();
  });
  //取消订单
  $(".abolish").live("click",function(){
       $(".popback").show();
       $(".poptagwindow2").show();
       index_info = $(this).parents("li").index();
  });
  $(".queren_info .quxiao").click(function(){
  		 $(".popback").hide();
       $(".pop").hide();
  });
  $(".quxiao").click(function(){
       $(".popback").hide();
       $(".pop").hide();
  });
  //删除包裹(订单)接口
  $(".queren_info .queding").click(function(){
  	$order_id = $(".list-status li").eq(index_info).find(".order_id").val();
  	$order_package_id = $(".list-status li").eq(index_info).find(".order_package_id").val();//获取包裹id
  	    $.ajax({
		 	type:"post",
		 	url:"../../order/Index/dealOrder",
		 	dataType:"json",
		 	data:{"order_id":$order_id,"user_id":$user_id,"order_package_id":$order_package_id,"flag":3},
		 	success:function(msg){
		 		if(msg.status==200){
		 			$(".popback").hide();
		       		$(".poptagwindow").hide();
		       		$(".list-status li").eq(index_info).remove();
		       		error("删除订单成功");
		       		var a_num = $(".order-status .cur").find(".num");
		       		if(a_num){
    		  	  a_num.text(parseInt(a_num.text())-1);
    		  	  if(a_num.text()==0){
    		  	  	a_num.hide();
    		  	  }
    		  }
		       		if($(".list-status li").length <1){
		       			notfound();
		       		}
		 		}else{
		 			  error(msg.errormsg);
		 		}
		 	}
 		})
  });

//取消订单接口
$(".queren_info2 .queding").click(function(){
    $order_id = $(".list-status li").eq(index_info).find(".order_id").val();
    $order_package_id = $(".list-status li").eq(index_info).find(".order_package_id").val();//获取包裹id
        $.ajax({
      type:"post",
      url:"../../order/Index/dealOrder",
      dataType:"json",
      data:{"order_id":$order_id,"user_id":$user_id,"order_package_id":$order_package_id,"flag":4},
      success:function(msg){
        if(msg.status==200){
          	  $(".popback").hide();
              $(".poptagwindow2").hide();
              $(".list-status li").eq(index_info).find('.name_status').text("订单已取消");
    		  $(".list-status li").eq(index_info).find('.fk a').eq(0).remove();
    		  $(".list-status li").eq(index_info).find('.fk .abolish').remove();
    		  var a = '<a href="javascript:" class="fr wypj delete mr-right-20">删除订单</a>';
    		  $(".list-status li").eq(index_info).find('.fk').append(a);
    		  error("取消订单成功！");
    		  var a_num = $(".order-status li").eq(1).find(".num");
    		  if(a_num){
    		  	  a_num.text(parseInt(a_num.text())-1);
    		  	  if(a_num.text()==0){
    		  	  	a_num.hide();
    		  	  }
    		  }
        }else{
             error(msg.errormsg);
        }
      }
    })
  });

 //确认收货接口
 $(".qrsh").live("click",function(){
 	 index_info = $(this).parents("li").index();
 	 $order_id  = $(".list-status li").eq(index_info).find(".order_id").val();
 	 $order_package_id = $(".list-status li").eq(index_info).find(".order_package_id").val();//获取包裹id
 	 $.ajax({
 	 	type:"post",
 	 	url:"../../order/Index/reciveProduct",
 	 	dataType:"json",
 	 	data:{"order_id":$order_id,"user_id":$user_id,"order_package_id":$order_package_id},
 	 	success:function(msg){
 	 		if(msg.status==200){
 	 		error("确认收货成功！");
 	 		window.setTimeout(function(){
 	 		window.location.href = "/order/index/myOrderList?order_state=50"},2000);
 	 		}else{ error(msg.errormsg);}
 	 	}
 	 });
 });

$(".fukuan").live("click",function(){
    var user_id=$("#user_id").val();
    var order_id=$(this).parents("li").find(".order_id").val();
    getpayUrl(order_id)
 })
$(".detailpay").live("click",function(){
    var user_id=$("#user_id").val();
    var order_id=$("#order_id").val();
    getpayUrl(order_id)
})
 //跳转支付页面
    function getpayUrl(order_id){
         location.href="/pay/Index/payType?order_id="+order_id;
    }